<%@ page contentType="text/html;charset=utf-8" language="java" %>
<%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <base href="<%=basePath%>">
    <meta charset="UTF-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" type="text/css" href="<c:url value='/resource/css/main.css'/>"/>
    <script type="text/javascript" src="<c:url value='/resource/js/jquery-1.11.1.min.js'/>"></script>
    <script type="text/javascript" src="<c:url value='/resource/js/num-alignment.js'/>"></script>
    <script type="text/javascript" src="<c:url value='/resource/js/jquery.cookie.js'/>"></script>
    <title>评审资料审核</title>
    <style type="text/css">
        .pssh{width:100%;height:46px;float:left;line-height:46px;border-top:1px solid #e5e5e5;border-bottom:1px solid #e5e5e5;position: fixed;left: 0;bottom: 0;background: #fff;}
        .pssh li{width: 50%;float: left;text-align: center;}
        .pssh li:last-child{border-right: 0;}
        .pssh li.cho{background: #e4e9f7;color: #3864cb;}
    </style>
</head>
<body>
<div class="btn_box4">
    <a href="profile/index.html" class=" back">返回</a>
    <a href="profile/logout" class=" logout">注销</a>
</div>
<div id="tab_ul">
    <ul class="zczh_sh" id="pssl_ul" style="display:none;">
        <li>
            <i>项目编号</i>
            <input class="gsname" id="projectno_pssl" value="" type="text" placeholder="请输入项目编号"/>
        </li>
        <li>
            <i>项目名称</i>
            <input class="gsname" id="projectname_pssl" value="" type="text" placeholder="请输入项目名称"/>
        </li>
        <li>
            <i>区域</i>
            <select class="area_ipt" id="select_pssl">
                <option value="">请选择</option>
                <c:forEach items="${regional}" var="list">
                    <option value="${list.regionid}">${list.regionname}</option>
                </c:forEach>
            </select>
        </li>
    </ul>
    <ul class="zczh_sh" id="cqzj_ul" style="display:none;">
        <li>
            <i>项目编号</i>
            <input class="gsname" id="projectno_cqzj" value="" type="text" placeholder="请输入项目编号"/>
        </li>
        <li>
            <i>项目名称</i>
            <input class="gsname" id="projectname_cqzj" value="" type="text" placeholder="请输入项目名称"/>
        </li>
        <li>
            <i>区域</i>
            <select class="area_ipt" id="select_cqzj">
                <option value="">请选择</option>
                <c:forEach items="${regional}" var="list">
                    <option value="${list.regionid}">${list.regionname}</option>
                </c:forEach>
            </select>
        </li>
    </ul>
</div>
<div class="btn_box">
    <input type="button" value="查询" class="search_btn all_btn" onclick="query();"/>
</div>

<div id="tab_box">
    <!--评审受理-->
    <div class="zczh_ch_tab pssh_box" style="display: none;">
        <table id="pssl" width="100%" border="0" cellspacing="0" cellpadding="0" class="table">
            <thead class="thead">
            <tr>
                <td width="35%">项目编号</td>
                <td width="44%">项目名称</td>
                <td width="21%" class="nobg">操作</td>
            </tr>
            </thead>
            <tbody id="pssl_tb">
            </tbody>
        </table>
        <a onclick="queryMore('pssl');" id="queryMore_pssl" class="click_more">点击查看更多信息...</a>
    </div>
    <!--抽取专家-->
    <div class="zczh_ch_tab pssh_box" style="display: none;">
        <table id="cqzj" width="100%" border="0" cellspacing="0" cellpadding="0" class="table">
            <thead class="thead">
            <tr>
                <td width="35%">项目编号</td>
                <td width="44%">项目名称</td>
                <td width="21%" class="nobg">操作</td>
            </tr>
            </thead>
            <tbody id="cqzj_tb">
            <%--<tr>--%>
            <%--<td>GC201705_0045</td>--%>
            <%--<td class="sec">--%>
            <%--<a href="xm_detail.html">苏地2011-B-57号 地块项目</a>--%>
            <%--</td>--%>
            <%--<td>--%>
            <%--<a href="cqzj.html" class="shenbao">抽取专家</a>--%>
            <%--</td>--%>
            <%--</tr>--%>
            </tbody>
        </table>
        <a onclick="queryMore('cqzj');" id="queryMore_cqzj" class="click_more">点击查看更多信息...</a>
    </div>
</div>
<ul class="pssh" id="pssh_tab">
    <li class="cho">评审受理</li>
    <li>抽取专家</li>
</ul>
</div>
<script type="text/javascript">
    $(document).ready(function () {
        $("#pssh_tab > li").click(function () {
            $(this).addClass("cho").siblings().removeClass("cho");
            var bb = $(this).index();
            $("#tab_box > .zczh_ch_tab").eq(bb).show().siblings().hide();//表格
            $("#tab_ul > .zczh_sh").eq(bb).show().siblings().hide();//查询条件
        });
    });
</script>
<script type="text/javascript">

    var totlePage_pssl;//总页数
    var pageNum_pssl;//当前页数
    var total_pssl;//总数据量

    var totlePage_cqzj;//总页数
    var pageNum_cqzj;//当前页数
    var total_cqzj;//总数据量

    $(function () {
        var tab = $.cookie('tab');
        if (tab == "pssl" || tab == null) {
            $("#pssh_tab > li").eq(0).click();
        } else if (tab == "cqzj") {
            $("#pssh_tab > li").eq(1).click();
        }
        loadPSSL();
        loadCQZJ();
        clearCookie();

    });
    //搜索条件查询
    function query() {
        //显示的查询条件标签
        var id = $(".zczh_sh:visible").attr("id");
        if (id == "pssl_ul") {
            //清空条件后查询
            $("#pssl_tb").empty();//列表
            pageNum_pssl = 1;//页数
            loadPSSL();
        } else if (id == "cqzj_ul") {
            $("#cqzj_tb").empty();//列表
            pageNum_pszj = 1;//页数
            loadCQZJ();
        }
    }

    //加载评审受理
    function loadPSSL() {
        $.ajax({
            url: "<c:url value="pssh/getPssl"/>",
            type: "post",
            async: false,
            dataType: "json",
            data: {
                projectno: $("#projectno_pssl").val(),
                projectname: $("#projectname_pssl").val(),
                regionid: $("#select_pssl").val(),
                pageNum: pageNum_pssl
            },
            success: function (resp) {
                if (resp.succ && resp.data.list.length > 0) {
                    total_pssl = resp.data.page;
                    pageNum_pssl = resp.data.pageNum;
                    var data = resp.data.list;
                    var html = "";
                    for (var i = 0; i < data.length; i++) {
                        html += "<tr>" +
                                "<td>" + data[i].projectno + "</td>" +
                                "<td> <a onclick=\"showDetail('" + data[i].guid + "','pssl')\">" + data[i].projectname + "</a></td>" +
                                "<td class=\"shenbao\" onclick=\"pssl_approval('" + data[i].guid + "',this);\">通过</td></tr>";
                    }
                    $("#pssl_tb").append(html);
                } else {
                    if ($("#pssl_tb tr").length == 0) {

                        $("#pssl_tb").append("<tr><td colspan='3'>未查出数据</td></tr>");
                    }
                }
                hide_queryMore("pssl");//判断是否影藏获取更多按钮
            },
            error: function () {
                alert("请求错误");
                return false;

            }
        });
    }

    //加载抽取专家
    function loadCQZJ() {
        $.ajax({
            url: "<c:url value="pssh/getCqzj"/>",
            type: "post",
            async: false,
            dataType: "json",
            data: {
                projectno: $("#projectno_cqzj").val(),
                projectname: $("#projectname_cqzj").val(),
                regionid: $("#select_cqzj").val(),
                pageNum: pageNum_cqzj
            },
            success: function (resp) {
                if (resp.succ && resp.data.list.length > 0) {
                    total_cqzj = resp.data.page;
                    pageNum_cqzj = resp.data.pageNum;
                    var data = resp.data.list;
                    var html = "";
                    for (var i = 0; i < data.length; i++) {
                        html += "<tr>" +
                                "<td>" + data[i].projectno + "</td>" +
                                "<td> <a onclick=\"showDetail('" + data[i].guid + "','cqzj')\">" + data[i].projectname + "</a></td>" +
                                "<td><a class=\"shenbao\" onclick=\"cqzj('" + data[i].guid + "','cqzj')\">抽取专家</td></tr>";
                    }
                    $("#cqzj_tb").append(html);
                } else {
                    if ($("#cqzj_tb tr").length == 0) {

                        $("#cqzj_tb").append("<tr><td colspan='3'>未查出数据</td></tr>");
                    }
                }
                hide_queryMore("cqzj");//判断是否影藏获取更多按钮
            },
            error: function () {
                alert("请求错误");
                return false;

            }
        });
    }

    //加载更多按钮隐藏或者显示
    function hide_queryMore(flag) {
        if (flag == "pssl") {
            if (pageNum_pssl == total_pssl) {
                $("#queryMore_pssl").hide();
            } else {
                $("#queryMore_pssl").show()
            }
        } else if (flag == "cqzj") {
            if (pageNum_cqzj == total_cqzj) {
                $("#queryMore_cqzj").hide();
            } else {
                $("#queryMore_cqzj").show()
            }
        }
    }
    //加载更多
    function queryMore(flag) {
        if (flag == "pssl") {
            if (pageNum_pssl < total_pssl) {
                pageNum_pssl++;
                loadPSSL();
            }
        } else if (flag == "cqzj") {
            if (pageNum_cqzj < total_cqzj) {
                pageNum_cqzj++;
                loadCQZJ();
            }
        }
    }
    //评审受理通过
    function pssl_approval(guid, obj) {
        if (!confirm("确定要通过此项目吗？")) {
            return false;
        } else {
            $.ajax({
                url: "<c:url value="pssh/psslApproval"/>",
                type: "post",
                async: false,
                dataType: "json",
                data: {
                    guid: guid
                },
                success: function (resp) {
                    if (resp.succ) {
                        alert(resp.msg);
                        //query();
                        $(obj).parent().remove();
                        $("#cqzj_tb").empty();//列表
                        pageNum_pssl = 1;//页数
                        loadCQZJ();
                    } else {
                        alert(resp.msg);
                        return false;
                    }
                }
            });
        }
    }
    //显示详情
    function showDetail(id, flag) {
        setCookie(flag);
        window.location.href = "pssh/getDetail/" + id;
    }
    function cqzj(id,flag){
        setCookie(flag);
        window.location.href = "pssh/getZJ/" + id;
    }
    //存入cookie
    function setCookie(flag) {
        $.cookie('tab', flag);//当前标签页
        if (flag == "pssl") {
            $.cookie('pageNum', pageNum_pssl);//当前标签页
        } else if (flag == "cqzj") {
            $.cookie('pageNum', pageNum_cqzj);//当前标签页
        }
    }
    //清除cookie
    function clearCookie() {
        $.cookie('tab', null);
        $.cookie('pageNum', null);
    }
</script>
</body>
</html>